﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.LightSwitch;
using LightSwitchApplication.UserCode;
namespace LightSwitchApplication
{
    public partial class PurchaseOrder
    {
        partial void PurchaseOrder_Created()
        {
            this.DocumentDate = DateTime.Now;

            this.DocumentID = Uti.GetAutoNumber(this.DataWorkspace, "PO"); 
        }

        partial void AmountTotal_Compute(ref decimal result)
        {
            // Set result to the desired field value
            result = this.PurchaseOrderDetails.Sum(o => o.AmountAfterTax).Value;   
        }
    }
}
